package com.yuan.task.service.impl;

import cn.common.utils.UserContextUtils;
import cn.model.MemberTask;
import com.yuan.task.mapper.MemberTaskMapper;
import com.yuan.task.service.MemberTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Slf4j
@Service
public class MemberTaskServiceImpl implements MemberTaskService {

    @Autowired
    private MemberTaskMapper memberTaskMapper;
    @Override
    //@Transactional(rollbackFor = Exception.class)
    public boolean saveMemberTask(MemberTask memberTask) {
        String MemberId = UserContextUtils.getCurrentUserId();
        log.info("用户id: {}",MemberId);
        memberTask.setMemberId(MemberId);
        memberTask.setCreateTime(new Date());
        memberTask.setTaskImg("111");
        memberTask.setTaskName("s");
        log.info("memberTask: {}",memberTask);
        int in = memberTaskMapper.insert(memberTask);
        System.out.println(in);
        return true;
    }

    @Override
    public List<MemberTask> getMemberTask(String memberId) {
        return List.of();
    }
}
